<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
 <script>
     function Animal() {
 
}
function Humen() {

}
Humen.prototype = new Animal()
var xiaoming = new Humen()

console.log(xiaoming instanceof Animal)



console.log(Object.prototype.toString.call(100)) //[object Number]
console.log(Object.prototype.toString.call('abc')) //[object String]
console.log(Object.prototype.toString.call([1, 2, 3])) //[object Array]
console.log(Object.prototype.toString.call({})) //[object Object]
console.log(Object.prototype.toString.call(function () { })) //[object Function]
console.log(Object.prototype.toString.call(true)) //[object Boolean]


//constructor可以用来判断数据类型   
//typeof  只能判断基础
//instanceof 只能判断引用数据类型
//Object.prototype.toString.call()

//面试题：请你创建一个函数，函数接受一个参数，返回传入参数的类型

function getType(data) {
    data = Object.prototype.toString.call(data)
    var now = data.split(' ')[1]
    return now.slice(0, now.length - 1).toLowerCase()
}

console.log(getType('abc'))   //string
console.log(getType(100))  //number
console.log(getType([1, 2, 3])) //array
console.log(getType(true)) //boolean
console.log(getType(function () { })) //function
console.log(getType({}))  //object

 </script>   
</body>
</html>